<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns a list of response headers sent (or ready to send)</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.header.html">header</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.headers-sent.html">headers_sent</a></div>
 <div class="up"><a href="ref.network.html">Network 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.headers-list" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">headers_list</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">headers_list</span> &mdash; <span class="dc-title">Returns a list of response headers sent (or ready to send)</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.headers-list-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>headers_list</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   <span class="function"><strong>headers_list()</strong></span> will return a list of headers to be sent
   to the browser / client.  To determine whether or not these headers have
   been sent yet, use <span class="function"><a href="function.headers-sent.html" class="function">headers_sent()</a></span>.
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.headers-list-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a numerically indexed array of headers.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.headers-list-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4393">
    <p><strong>Example #1 Examples using <span class="function"><strong>headers_list()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/*&nbsp;setcookie()&nbsp;will&nbsp;add&nbsp;a&nbsp;response&nbsp;header&nbsp;on&nbsp;its&nbsp;own&nbsp;*/<br /></span><span style="color: #0000BB">setcookie</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Define&nbsp;a&nbsp;custom&nbsp;response&nbsp;header<br />&nbsp;&nbsp;&nbsp;This&nbsp;will&nbsp;be&nbsp;ignored&nbsp;by&nbsp;most&nbsp;clients&nbsp;*/<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"X-Sample-Test:&nbsp;foo"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;Specify&nbsp;plain&nbsp;text&nbsp;content&nbsp;in&nbsp;our&nbsp;response&nbsp;*/<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;text/plain'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;What&nbsp;headers&nbsp;are&nbsp;going&nbsp;to&nbsp;be&nbsp;sent?&nbsp;*/<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">headers_list</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
  [0]=&gt;
  string(23) &quot;X-Powered-By: PHP/5.1.3&quot;
  [1]=&gt;
  string(19) &quot;Set-Cookie: foo=bar&quot;
  [2]=&gt;
  string(18) &quot;X-Sample-Test: foo&quot;
  [3]=&gt;
  string(24) &quot;Content-type: text/plain&quot;
}

</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.headers-list-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
<p class="para">
 数据头只会在SAPI支持时得到处理和输出。
</p>
</p></blockquote>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.headers-list-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.headers-sent.html" class="function" rel="rdfs-seeAlso">headers_sent()</a> - Checks if or where headers have been sent</span></li>
    <li class="member"><span class="function"><a href="function.header.html" class="function" rel="rdfs-seeAlso">header()</a> - Send a raw HTTP header</span></li>
    <li class="member"><span class="function"><a href="function.setcookie.html" class="function" rel="rdfs-seeAlso">setcookie()</a> - Send a cookie</span></li>
    <li class="member"><span class="function"><a href="function.apache-response-headers.html" class="function" rel="rdfs-seeAlso">apache_response_headers()</a> - Fetch all HTTP response headers</span></li>
    <li class="member"><span class="function"><a href="function.http-response-code.html" class="function" rel="rdfs-seeAlso">http_response_code()</a> - Get or Set the HTTP response code</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.header.html">header</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.headers-sent.html">headers_sent</a></div>
 <div class="up"><a href="ref.network.html">Network 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
